local skel = fk.CreateSkill{
  name = "kqf__shejin",
}

Fk:loadTranslationTable{
  ["kqf__shejin"] = "涉矜",
  [":kqf__shejin"] = "当你的体力值变化后，你可以弃置一名角色至多三张牌，然后其可以摸等量张牌并明置，且其本回合不能使用暗置牌。",

  ["#kqf__shejin_ask"] = "涉矜：你可以弃置一名角色至多三张牌，然后其可以摸等量张牌并明置，且其本回合不能使用暗置牌",
  ["#kqf__shejin_ask2"] = "摸 %arg 张牌并明置，且本回合不能使用暗置牌",
  ["@@kqf__shejin-turn"] = "涉矜",

  ["$kqf__shejin1"] = "尔等欺君罔上，还敢抵赖？",
  ["$kqf__shejin2"] = "哼，真以为我会饶过你？",
}

local DIY = require "packages/diy_utility/diy_utility"

skel:addEffect(fk.HpChanged, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.filter(room:getAllPlayers(), function (p)
      return not p:isNude()
    end)
    local to = room:askToChoosePlayers(player, {
      targets = targets,
      min_num = 1,
      max_num = 1,
      prompt = "#kqf__shejin_ask",
      skill_name = skel.name,
      cancelable = true,
      })
    if #to > 0 then
      event:setCostData(self, {tos = to})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    local cards = room:askToChooseCards(player, {
      min = 1,
      max = 3,
      target = to,
      flag = "he",
      skill_name = skel.name,
    })
    room:throwCard(cards, skel.name, to, player)
    local choose2 = room:askToChoice(to, {
      choices = {"#kqf__shejin_ask2:::" .. #cards,"Cancel"},
      skill_name = skel.name,
      cancelable = false,
    })
    if choose2:startsWith("#kqf__shejin_ask2:") then
      local dcards = to:drawCards(#cards,skel.name)
      DIY.showCards(to,dcards)
      room:setPlayerMark(to, "@@kqf__shejin-turn", 1)--本回合不能使用非明置牌的标记
    end
  end,
})

skel:addEffect("prohibit", {
  prohibit_use = function(self, player, card)
    if player:getMark("@@kqf__shejin-turn") > 0 then
      local subcards = card:isVirtual() and card.subcards or {card.id}
      return #subcards > 0 and not table.every(subcards, function(id)
        return table.contains(DIY.getShownCards(player), id)
      end)
    end
  end,
})

return skel